const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const path = require('path')
const app = express()
app.use(express.static("public"))
app.use("/node_modules", express.static(path.join(__dirname, "/node_modules")))
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded())

// parse application/json
app.use(bodyParser.json())
const indexRouter = require("./routers");
const {
    error
} = require('console');
app.use("/", indexRouter)
mongoose.connect("mongodb://localhost/bo445stu2").then(() => {
    console.log('连接数据库成功');
    app.listen(3001, () => {
        console.log('服务器已启动');

    })

}).catch(error => {
    console.log('连接数据库失败', error);
})